<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.9
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

class JFX_Module_Blockstyle_Property_Border extends JFX_Module_Blockstyle_Property_Base
{
	public $id = 'border';
	public $cssName = 'border';
	public $title = 'Border';
	public function init(){
		$this->title = 'Border';

		$borderCornerWidget = new JFX_Module_Blockstyle_Widget_Bordercorner($this, $this->instanceId.'-bordercorner');
		$this->widgets[] = $borderCornerWidget;

		$borderWidget = new JFX_Module_Blockstyle_Widget_Border($this, $this->instanceId.'-borders');
		$this->widgets[] = $borderWidget;


	}
	public function __toCss(){
		$outputString = '';

		if($this->getWidget($this->instanceId.'-borders')->enabled){
			$outputString .= 'border-top: '.$this->getCssValue('top').";\n";
			$outputString .= 'border-right: '.$this->getCssValue('right').";\n";
			$outputString .= 'border-bottom: '.$this->getCssValue('bottom').";\n";
			$outputString .= 'border-left: '.$this->getCssValue('left').";\n";

			$cornerWidget = $this->getWidget($this->instanceId.'-bordercorner');
			$outputString .= 'border-top-left-radius: '.$cornerWidget->topleftValue1.'px '.$cornerWidget->topleftValue2."px;\n";
			$outputString .= '-moz-border-radius-topleft: '.$cornerWidget->topleftValue1."px;\n";
			$outputString .= '-webkit-border-top-left-radius: '.$cornerWidget->topleftValue1."px;\n";

			$outputString .= 'border-top-right-radius: '.$cornerWidget->toprightValue1.'px '.$cornerWidget->toprightValue2."px;\n";
			$outputString .= '-moz-border-radius-topright: '.$cornerWidget->toprightValue1."px;\n";
			$outputString .= '-webkit-border-top-right-radius: '.$cornerWidget->toprightValue1."px;\n";

			$outputString .= 'border-bottom-right-radius: '.$cornerWidget->bottomrightValue1.'px '.$cornerWidget->bottomrightValue2."px;\n";
			$outputString .= '-moz-border-radius-bottomright: '.$cornerWidget->bottomrightValue1."px;\n";
			$outputString .= '-webkit-border-bottom-right-radius: '.$cornerWidget->bottomrightValue1."px;\n";

			$outputString .= 'border-bottom-left-radius: '.$cornerWidget->bottomleftValue1.'px '.$cornerWidget->bottomleftValue2."px;\n";
			$outputString .= '-moz-border-radius-bottomleft: '.$cornerWidget->bottomleftValue1."px;\n";
			$outputString .= '-webkit-border-bottom-left-radius: '.$cornerWidget->bottomleftValue1."px;\n";
		}




		return $outputString;

	}

	public function getCssValue($side){
		return $this->getWidget($this->instanceId.'-borders')->getCssValue($side);
	}


}



